using System;
using System.Windows.Forms;
using System.Reflection;
using ARCam3D.UI.Forms;

namespace ARCam3D
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }

        public static string AssemblyVersion
        {
            get
            {
                return Assembly.GetExecutingAssembly().GetName().Version.ToString();
            }
        }

        public static string AssemblyTitle
        {
            get
            {
                object attribute = getAssemblyCustomAttribute(typeof(AssemblyTitleAttribute));
                if (attribute != null)
                {
                    return ((AssemblyTitleAttribute)attribute).Title;
                }
                else
                {
                    return "";
                }
            }
        }

        public static string AssemblyDescription
        {
            get
            {
                object attribute = getAssemblyCustomAttribute(typeof(AssemblyDescriptionAttribute));
                if (attribute != null)
                {
                    return ((AssemblyDescriptionAttribute)attribute).Description;
                }
                else
                {
                    return "";
                }
            }
        }

        public static string AssemblyProduct
        {
            get
            {
                object attribute = getAssemblyCustomAttribute(typeof(AssemblyProductAttribute));
                if (attribute != null)
                {
                    return ((AssemblyProductAttribute)attribute).Product;
                }
                else
                {
                    return "";
                }
            }
        }

        public static string AssemblyCopyright
        {
            get
            {
                object attribute = getAssemblyCustomAttribute(typeof(AssemblyCopyrightAttribute));
                if (attribute != null)
                {
                    return ((AssemblyCopyrightAttribute)attribute).Copyright;
                }
                else
                {
                    return "";
                }
            }
        }

        public static string AssemblyCompany
        {
            get
            {
                object attribute = getAssemblyCustomAttribute(typeof(AssemblyCompanyAttribute));
                if (attribute != null)
                {
                    return ((AssemblyCompanyAttribute)attribute).Company;
                }
                else
                {
                    return "";
                }
            }
        }

        private static object getAssemblyCustomAttribute(Type type)
        {
            object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(type, false);

            if (attributes.Length > 0)
            {
                return attributes[0];
            }
            else
            {
                return null;
            }
        }
    }
}

